<template>
  <transition name="scale-fade">
    <div class="page f_c_a_c" v-show="isShow">
      <div class="cover"></div>
      <slot name="content"></slot>
      <div class="icon close_icon" v-show="isShowClose" @click="handleClose"></div>
    </div>
  </transition>
</template>

<script>
export default {
  name: "Modal",
  props: {
    isShow: {
      type: Boolean,
      default: false
    }
  },
  components: {},
  data() {
    return {
      isShowClose: true
    };
  },
  watch: {},
  computed: {},
  methods: {
    handleClose: function() {
      this.$emit("close");
    }
  },
  created() {},
  mounted() {
    this.$nextTick(function() {
      let screenHeight = document.body.offsetHeight;
      window.onresize = () => {
        let nowHeight = document.body.offsetHeight;
        if (nowHeight < screenHeight) {
          // 将底部弹起的按钮隐藏
          this.isShowClose = false;
        } else {
          // 将按钮正常显示
          this.isShowClose = true;
        }
      };
    });
  },
  destroyed() {}
};
</script>

<style lang="scss" scoped>
.scale-fade-enter-active {
  transition: all 0.3s ease-in-out;
}
.scale-fade-leave-active {
  transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.scale-fade-enter,
.scale-fade-leave-to {
  opacity: 0;
}
.cover {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: black;
  opacity: 0.6;
  z-index: 98;
  transition: all 0.3s ease;
}

.page {
  z-index: 1000;
  position: fixed;
  left: 0;
  top: 0;
  .close_icon {
    z-index: 1111;
    // position: absolute;
    // bottom: 158px;
    // left: 50%;
    // margin-left: -30px;
    background-image: url("/game/static/images/six_skills/close.png");
    // margin-top: 50px;
  }
}
</style>
